package chapter12;

import javax.swing.*;
import java.awt.*;

public class TestImageIcon extends JFrame {
	
	String catPath = "chapter12/image/cat.jpg";
	String dogPath = "chapter12/image/dog.jpg";
	private ImageIcon catIcon = new ImageIcon(ClassLoader.getSystemResource(catPath));
	private ImageIcon dogIcon = new ImageIcon(ClassLoader.getSystemResource(dogPath));
	
	public TestImageIcon(){
		setLayout(new GridLayout(1, 2, 5, 5));
		add(new JLabel(catIcon));
		add(new JLabel(dogIcon));
	}
	

	public static void main(String[] args) {
		// 为什么不会显示图像呢？
		TestImageIcon frame = new TestImageIcon();
		frame.setTitle("TestImageIcon");
		frame.setSize(300, 500);
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}

}
